{% extends "base_index.html" %}
{% load commonFilters %}
{% load i18n %}

{% comment %}
copyright (c) 2009, paketka@gmail.com et. al
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

	* Redistributions of source code must retain the above copyright notice,
	  this list of conditions and the following disclaimer.

	* Redistributions in binary form must reproduce the above copyright notice,
	  this list of conditions and the following disclaimer in the documentation
	  and/or other materials provided with the distribution.

	* Neither the name of the <ORGANIZATION> nor the names of its contributors
	  may be used to endorse or promote products derived from this software
 	  without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{% endcomment %}

{% block rss-link %}
<link rel="alternate" type="application/rss+xml" title="RSS-poslanci" href="{% url rss_link "hlasovani" %}" />
{% endblock %}

{% block keywords %}
uskutečněná hlasování, hlasování dne {{ pollDate|date:"Y m d" }}, výsledky hlasování,
přehled výsledků hlasování
{% endblock %}
{% block javascript-head %}
	var filterEnabled = false;
	function getDataUrl()
	{
		var retVal = "";

		if (filterEnabled)
			retVal = '{% url json.views.get_polls_in_day pollDate.year, pollDate.month, pollDate.day %}' + '?filterProcedural=1';
		else
			retVal = '{% url json.views.get_polls_in_day pollDate.year, pollDate.month, pollDate.day %}';

		return retVal
	}

	$(document).ready(function(){
		$("#poll-list").jqGrid({
					url: getDataUrl(),
					datatype: 'json',
					colNames: [	"{% trans "Číslo hlasování" %}",
								"{% trans "Název hlasování" %}",
								"{% trans "Výsledek" %}",
								"{% trans "Pro" %}",
								"{% trans "Proti" %}",
								"{% trans "Zdrželo" %}",
								"{% trans "Nepřítomno" %}"
						],
					colModel :[
						{ name: "pollNo", index: "pollNo", width: 80, jsonmap: "pollNo", sortable: false },
						{ name: "name", index: "name", width: 200, jsonmap: "name", sortable: false },
						{ name: "result", index: "result", width: 120, jsonmap:"result", sortable: false },
						{ name: "aye", index: "aye", width:80, jsonmap:"aye", sortable: false },
						{ name: "nay", index: "nay", width: 80, jsonmap: "nay", sortable: false  },
						{ name: "refrain", index: "refrain", width: 80, jsonmap: "refrain", sortable: false },
						{ name: "absences", index: "absences", width: 80, jsonmap: "absences", sortable: false}
					], 
					pager: $('#poll-pager'),
					jsonReader: {
						root: "rows",
						id: "pk",
						page: "page",
						total: "total",
						records: "records",
						repeatitems: false
					},
					sortname:"start",
					sortorder:"desc",
					rowNum:20,
					rowList:[10,15,20],
					viewrecords:true,
					caption:"{% trans "Seznam hlasování" %} {{ poll.date|date:"d M Y" }}",
					width:740,
					height:300,
					toolbar: [true,'top']
		});
		$("#t_poll-list").filterGrid("#poll-list", {
				gridModel: false,
				gridToolBar: false,
				filterModel: [ {
					label: '',
					name: 'filter__exp',
					stype: 'text',
					defval: ''
				} ],
				autosearch: true,
				searchButton: '{% trans "Hledej" %}',
				enableSearch: true
		});

		$("#stat-tab").tabs();

	});

function filterProcedural(id)
{
	if (filterEnabled) {
		filterEnabled = false;
	}
	else {
		filterEnabled = true;
	}

	$("#poll-list").setGridParam({ url: getDataUrl() }).trigger("reloadGrid");
}

{% endblock %}

{% block left-sidebar %}
	<div class="ui-widget">
		<div class="ui-widget-header">
			<h1>{% trans "Kalendář hlasování" %}</h1>
		</div>
		<div class="ui-widget-content">
			<div class="container">
				{% url json.views.get_meetings_in_month poll.date.year,poll.date.month as events %}
				{% url psp.views.show_day_polls poll.date.year,poll.date.month,poll.date.day as eventDetails %}
				{% datepicker "meetingPicker" events eventDetails poll.date %}
			</div>
		</div>
	</div>
{% endblock %}

{% block content %}

<div class="ui-widget">
</div>

<div id="stat-tab">
	<ul>
		<li><a href="#day">{% trans "Dnes" %}</a></li>
		<li><a href="week">{% trans "Týden" %}</a></li>
		<li><a href="month">{% trans "Měsíc" %}</a></li>
		<li><a href="term">{% trans "Období" %}</a></li>
		<li><a href="celkem">{% trans "Celkem" %}</a></li>
	</ul>

<div class="ui-widget">
	<div class="ui-widget-header">
		<h1>{% trans "Projednané návrhy" %} {{ poll.date|date:"d M Y" }}</h1>
	</div>
	<div class="ui-widget-content">
		<p>
		<input type="checkbox" id="filterProcedural" onclick="filterProcedural(this.checked)"> {% trans "Skryj procedurální hlasování" %}  <br/> 
		<table id="poll-list" class="scroll" cellpadding="0" cellspacing="0"></table>
		<div id="poll-pager" class="scroll" style="text-align:center;"></div>
		</p>
	</div>
</div>

</div>
{% endblock %}
